package com.tangly.module.controller;

import com.tangly.common.base.BaseController;
import com.tangly.module.entity.BannerEntity;
import com.tangly.module.vo.AppBannerVO;
import com.tangly.module.vo.ResultVO;
import com.tangly.module.service.IBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * created by yehao on 2018/7/24.
 */
@RestController
@RequestMapping(value = "/app/home")
@Slf4j
@Api(tags = "banner图片获取")
public class AppBannerController extends BaseController {

    @Autowired
    private IBannerService iBannerService;

    @ApiOperation(value ="获取banner图片列表")
    @GetMapping(value = "banner")
    public ResultVO<AppBannerVO> getList(){
        List<BannerEntity> bannerEntityList=iBannerService.selectAll();
        List<AppBannerVO> list=new ArrayList<>();
        for (BannerEntity bannerEntity: bannerEntityList){
            list.add(AppBannerVO.convert(bannerEntity));
        }
        return  new ResultVO<>(list);
    }




}
